class IT:
    def __init__(self, max_num):
        self.max_num = max_num

    def __iter__(self):
        return self.IterRange(self.max_num + 1)

    class IterRange:
        def __init__(self, num):
            self.num = num
            self.count = 0

        def __iter__(self):
            return self

        def __next__(self):
            self.count += 1
            if self.count == self.num:
                raise StopIteration()
            return self.count


class IterRange:
    def __init__(self, num):
        self.num = num
        self.count = 0

    def __iter__(self):
        return self

    def __next__(self):
        self.count += 1
        if self.count == self.num:
            raise StopIteration()
        return self.count


if __name__ == '__main__':
    obj = IT(10)
    for i in obj:
        print(i)
    print('next')
    obj2 = IterRange(10)
    for j in obj2:
        print(j)
